<!DOCTYPE html>


<html xmlns:th="http://www.w3.org/1999/xhtml" lang="zh">
<head th:fragment="head">
    <!--    Jpom                                                                                   -->
    <!--    The MIT License(MIT)                                                                   -->
    <!--    Copyright(c) 2019 码之科技工作室                                                        -->
    <!--    Permission is hereby granted,free of charge,to any person obtaining a copy of          -->
    <!--    this software and associated documentation files(the"Software"),to deal in             -->
    <!--    the Software without restriction,including without limitation the rights to            -->
    <!--    use,copy,modify,merge,publish,distribute,sublicense,and/or sell copies of              -->
    <!--    the Software,and to permit persons to whom the Software is furnished to do so,         -->
    <!--    subject to the following conditions:                                                   -->
    <!--    The above copyright notice and this permission notice shall be included in all         -->
    <!--    copies or substantial portions of the Software.                                        -->
    <!--    THE SOFTWARE IS PROVIDED"AS IS",WITHOUT WARRANTY OF ANY KIND,EXPRESS OR                -->
    <!--    IMPLIED,INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS         -->
    <!--    FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR          -->
    <!--    COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER LIABILITY,WHETHER           -->
    <!--    IN AN ACTION OF CONTRACT,TORT OR OTHERWISE,ARISING FROM,OUT OF OR IN                   -->
    <!--    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.             -->
    <!--    @author CodeGzh                                                                        -->
    <title>Jpom-项目管理系统</title>
    <meta name="keywords" content="Jpom,Java项目管理,Jar管理,Java管理系统,服务器项目运维"/>
    <meta name="description" content="Jpom-项目管理系统"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" name="viewport">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="icon" th:href="@{${session.jpomProxyPath}+'/static/favicon.ico'}"
          type="image/x-icon"/>
    <link rel="shortcut icon" th:href="@{${session.jpomProxyPath}+'/static/favicon.ico'}"
          type="image/x-icon"/>
    <link rel="stylesheet"
          th:href="@{${session.jpomProxyPath}+'/static/layui/css/layui.css?v='+${session.staticCacheTime}}"
          media="all">
    <style>
        body {
            padding: 10px;
        }

        .x-red {
            color: red;
        }

        .layui-table-hover {
            -webkit-box-shadow: inset 0 0 10px #8D8D8D;
            -moz-box-shadow: inset 0 0 10px #8D8D8D;
            box-shadow: inset 0 0 10px #8D8D8D;
        }

        .auto {
            width: 100%;
            height: 100%;
        }
    </style>
    <script type="text/javascript"
            th:src="@{${session.jpomProxyPath}+'/static/layui/layui.js?v='+${session.staticCacheTime}}"></script>
    <script type="text/javascript">
        let windowsOnload = false;
        /**
         * @param  {String} message 错误信息
         * @param  {String} source  发生错误的脚本URL
         * @param  {Number} lineno  发生错误的行号
         * @param  {Number} colno   发生错误的列号
         * @param  {Object} error   Error对象
         */
        window.onerror = function (message, source, lineno, colno, error) {
            // ...
        };
        window.onload = function () {
            windowsOnload = true;
        };
        let $, layer, form, element, table;
        const asyncFn = [];
        // 不缓存
        layui.config({
            version: true,
            base: '/static/layui/plugin/',
        });
        layui.use(['layer', 'element', 'form', 'table'], function () {
            $ = layui.$;
            // ztree 调用
            window.jQuery = $;
            element = layui.element;
            layer = layui.layer;
            form = layui.form;
            table = layui.table;
            var time = setInterval(function () {
                if (windowsOnload === true) {
                    clearInterval(time);
                    allLoadCall();
                }
            }, 200);
        });

        function allLoadCall() {
            //
            try {
                loadSuccess && loadSuccess();
            } catch (e) {
            }
            //
            layui.each(asyncFn, function () {
                try {
                    this && this();
                } catch (e) {
                    console.error(e);
                }
            });

            var jsCommonContext = document.getElementById("jsCommonContext").innerHTML;
            if (jsCommonContext && jsCommonContext !== '') {
                jsCommonContext = decodeURIComponent(jsCommonContext);
                $("body").append(jsCommonContext);
            }

            $("button[op='a']").click(function () {
                var href = $(this).attr("href");
                location.href = appendNodeId(href);
            });
        }

        function appendNodeId(url) {
            var nodeId = getTopQueryString("nodeId");
            if (nodeId) {
                return urlUpdateParams(url, "nodeId", nodeId);
            }
            return url;
        }

        function tabChange(options) {
            var element = top.layui.element;
            var lay_id = 'tab_' + options.id + options.title;
            options.url = appendNodeId(options.url);

            if ($('[lay-id="' + lay_id + '"]', top.document).length <= 0) {
                var tab_content = '<iframe id="' + lay_id + '" name="' + options.id + '" src="' + options.url + '" frameborder="0" class="custom-iframe"></iframe>';
                element.tabAdd('mainTabs', {
                    title: options.title,
                    content: tab_content,
                    id: lay_id
                });
            }
            element.tabChange('mainTabs', lay_id);
            var ddItem = $("dd[id='dd_" + options.id + "']");
            var hasClass = ddItem.hasClass('layui-this');
            if (!hasClass) {
                ddItem.find('a').click();
            }
        }

        function layerOpen(options) {
            if (options.type === 2) {
                options.content = appendNodeId(options.content);
            }
            var newData = {
                maxmin: true,
            };
            $.extend(newData, options);
            return layer.open(newData);
        }

        function getSocketHost() {
            var pro = location.protocol === 'https:' ? 'wss://' : 'ws://';
            return pro + window.location.host + "[[${session.jpomProxyPath}]]";
        }

        function getTopQueryString(name) {
            var val = getQueryStringByUrl(top.location.search.substr(1), name);
            if (!val) {
                val = getQueryString(name);
            }
            return val;
        }

        function getQueryString(name) {
            return getQueryStringByUrl(location.search.substr(1), name);
        }

        function getQueryStringByUrl(url, name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = url.match(reg);
            if (r != null)
                return decodeURI(r[2]);
            return null;
        }

        function urlUpdateParams(url, name, value) {
            var r = url;
            if (r != null && r != 'undefined' && r != "") {
                value = encodeURIComponent(value);
                var reg = new RegExp("(^|)" + name + "=([^&]*)(|$)");
                var tmp = name + "=" + value;
                if (url.match(reg) != null) {
                    r = url.replace(eval(reg), tmp);
                } else {
                    if (url.match("[\?]")) {
                        r = url + "&" + tmp;
                    } else {
                        r = url + "?" + tmp;
                    }
                }
            }
            return r;
        }

        // 带loading 效果的网络请求
        function loadingAjax(data, closeLoading) {
            var success = data.success;
            delete data.success;
            var error = data.error;
            delete data.error;

            var newData = {
                nodeId: getTopQueryString("nodeId")
            };
            $.extend(newData, data.data);
            delete data.data;

            var index;
            var defData = {
                type: 'POST',
                dataType: 'json',
                data: newData,
                beforeSend: function () {
                    if (closeLoading !== true) {
                        index = layer.load(1, {
                            shade: [0.3, '#fff']
                        });
                    }
                },
                success: function (data) {
                    layer.close(index);
                    if (data.code === 800) {
                        // 用户信息失效
                        layer.msg(data.msg);
                        setTimeout(function () {
                            top.location.reload();
                        }, 1500);
                        return;
                    }
                    if (data.code !== 200) {
                        if (!data.msg || data.msg === '') {
                            data.msg = "接口异常，并且没有返回异常信息"
                        }
                    }
                    success && success(data);
                },
                error: function () {
                    layer.close(index);
                    layer.msg("网络异常,请稍后再试");
                    error && error();
                },
                complete: function () {
                    data.complete && data.complete();
                }
            };
            $.extend(defData, data);
            $.ajax(defData);
        }

        // 静默ajax
        function silentAjax(data) {
            loadingAjax(data, true);
        }

        // 默认表格渲染
        function tableRender(data) {
            var done = data.done;
            delete data.done;
            var cols = data.cols;
            if (!(cols[0] instanceof Array)) {
                data.cols = [cols];
            }
            var newWhere = {
                nodeId: getTopQueryString("nodeId")
            };
            $.extend(newWhere, data.where);
            delete data.where;
            //
            const defData = {
                even: true,
                loading: true,
                method: 'POST',
                response: {
                    statusCode: 200
                },
                where: newWhere,
                done: function (data) {
                    if (data.code === 800) {
                        // 用户信息失效
                        layer.msg(data.msg);
                        setTimeout(function () {
                            top.location.reload();
                        }, 1500);
                        return;
                    }
                    done && done(data);
                }
            };
            $.extend(defData, data);
            table.render(defData);
        }

        //文件上传渲染
        function uploadRender(data, fn) {
            layui.use(['upload'], function () {
                function getUploadProgress() {
                    return data.openTop ? $("#uploadProgress", top.document) : $("#uploadProgress");
                }

                function getLayIndex(index) {
                    return data.openTop ? $("#layui-layer" + index, top.document) : $("#layui-layer" + index);
                }

                var upload = layui.upload;
                var newsData = {
                    nodeId: getTopQueryString("nodeId")
                };
                $.extend(newsData, data.data);
                delete data.data;
                let done = data.done;
                let allDone = data.allDone;
                delete data.done;
                delete data.allDone;
                // 打开层级
                var useLayer = data.openTop ? top.layer : layer;
                var useElement = data.openTop ? top.layui.element : element;
                const defData = {
                    data: newsData,
                    error: function () {
                        var openIndex = getUploadProgress().attr("index");
                        useLayer.close(openIndex);
                        useLayer.msg('上传异常');
                    },
                    before: function () {
                        var uploadProgress = getUploadProgress();
                        if (uploadProgress.length > 0) {
                            return
                        }
                        useLayer.open({
                            type: 1,
                            title: false,
                            closeBtn: 0,
                            area: ['80%', '10%'],
                            content: '<div style="text-align: center;margin:0 auto; width: 500px;height: 10%">' +
                                '       <div id="uploadProgress" class="layui-progress layui-progress-big" lay-showpercent="true" lay-filter="uploadProgress">\n' +
                                '           <div class="layui-progress-bar" lay-percent="0%"></div>\n' +
                                '       </div>' +
                                '     </div>',
                            success: function (l, index) {
                                useElement.render('progress');
                                getUploadProgress().attr("index", index);
                                getLayIndex(index).css("background-color", "transparent").css("box-shadow", "none");
                            }
                        });
                    },
                    done: function (res, index, upload) {
                        if (data.multiple !== true) {
                            var openIndex = getUploadProgress().attr("index");
                            useLayer.close(openIndex);
                        }
                        done && done(res, index, upload);
                    },
                    allDone: function (obj) {
                        var openIndex = getUploadProgress().attr("index");
                        useLayer.close(openIndex);
                        allDone && allDone(obj);
                    },
                    progress: function (n) {
                        var percent = n + '%';
                        useElement.progress('uploadProgress', percent);
                    }
                };
                $.extend(defData, data);
                var uploadResult = upload.render(defData);
                fn && fn(uploadResult);
            });
        }

        //格式化时间
        function formateTime(time) {
            if (!time) {
                return 0;
            }
            var date = new Date();
            date.setTime(time);
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            m = m < 10 ? ('0' + m) : m;
            var d = date.getDate();
            d = d < 10 ? ('0' + d) : d;
            var h = date.getHours();
            h = h < 10 ? ('0' + h) : h;
            var minute = date.getMinutes();
            var second = date.getSeconds();
            minute = minute < 10 ? ('0' + minute) : minute;
            second = second < 10 ? ('0' + second) : second;
            return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
        }

        // 异步加载js
        function asyncLoadJs(url, callback) {
            var script = document.createElement('script');
            script.type = "text/javascript";
            if (script.readyState) {
                script.onreadystatechange = function () {
                    if (script.readyState == "loaded" || script.readyState == "complete") {
                        script.onreadystatechange = null;
                        callback && callback();
                    }
                }
            } else {
                script.onload = function () {
                    callback && callback();
                }
            }
            script.src = url;
            document.body.appendChild(script);
        }

        function autoClose() {
            setTimeout(function () {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
                parent.location.reload();
            }, 2000);
        }

        function randomString(len) {
            var $chars = 'ABCDEFGHJKMNPQRSTWXYZ0123456789';
            /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
            var maxPos = $chars.length;
            var pwd = '';
            for (i = 0; i < len; i++) {
                pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
            }
            return pwd;
        }
    </script>

    <script id="jsCommonContext" type="text/html"
            th:utext="@{${#strings.defaultString(session.jsCommonContext,'')}}"></script>

    <!--  插件注入代码-->
    <th:block th:inline="javascript" th:utext="${#strings.defaultString(pagePluginHtml,'')}">
    </th:block>
</head>

</html>
